package org.siam.impl.schemas {
	
	import flash.utils.Dictionary;
	
	import org.siam.core.schemas.ISchema;
	import org.siam.core.schemas.ISchemaRegistry;
	
	public class SchemaRegistry implements ISchemaRegistry {
		
		private var _registry:Dictionary;
		
		public function SchemaRegistry() {
			_registry = new Dictionary();
		}
		
		public function register(name:String, schema:ISchema):void {
			_registry[name] = schema;			
		}
		
		public function find(name:String):ISchema {
			return _registry.hasOwnProperty(name)
					? _registry[name] : Schema.NULL;
		}
		
		public function get names():Array {
			var names:Array = new Array();
			for (var name:String in _registry) {
				names.push(name);
			}
			return names;
		}
	}
}